#include"MetaDataDisplay.h" 

MetaDataDisplay::MetaDataDisplay(QWidget *parent):QWidget(parent){
	m_layout = new QFormLayout(this);
	setLayout(m_layout);
	
	m_labelTitle = new QLabel();
	m_labelTitle->setWordWrap(true);
	m_layout->addRow("Playing:", m_labelTitle);
	
	m_labelArtist = new QLabel();
	m_layout->addRow("By:", m_labelArtist);
	m_labelTitle->setWordWrap(true);
	
	m_labelAlbum = new QLabel();
	m_layout->addRow("On:", m_labelAlbum);
	m_labelTitle->setWordWrap(true);
}

MetaDataDisplay::~MetaDataDisplay(){
	
}

void MetaDataDisplay::metaDataChanged( QMultiMap<QString, QString> data ){
	m_labelTitle->setText("");
	m_labelAlbum->setText("");
	m_labelArtist->setText("");
	
	if(data.isEmpty())
		return;
	
	QString string("");
	QMap<QString,QString>::iterator it;
	if( (it = data.find("TRACK-NUMBER")) != data.end() )
		string += "(" + it.value() + ") ";
	if( (it = data.find("TITLE")) != data.end() )
		string += it.value();
	m_labelTitle->setText(string);
	
	if( (it = data.find("ARTIST")) != data.end() )
		m_labelArtist->setText(it.value());
	
	if( (it = data.find("ALBUM")) != data.end() )
		m_labelAlbum->setText(it.value());
}

